package com.example.newdemo.view.image.svg;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Picture;
import android.graphics.RectF;
import android.util.Log;

import org.xml.sax.SAXException;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;


public class SVG {
    private static final String TAG = "AndroidSVG";
    private static final String VERSION = "1.2.1";
    protected static final String SUPPORTED_SVG_VERSION = "1.2";
    private static final int DEFAULT_PICTURE_WIDTH = 512;
    private static final int DEFAULT_PICTURE_HEIGHT = 512;
    private static final double SQRT2 = 1.414213562373095D;
    private static final List<SvgObject> EMPTY_CHILD_LIST = new ArrayList(0);
    private SVG.Svg rootElement = null;
    private String title = "";
    private String desc = "";
    private SVGExternalFileResolver fileResolver = null;
    private float renderDPI = 96.0F;
    private CSSParser.Ruleset cssRules = new CSSParser.Ruleset();
    protected static final long SPECIFIED_FILL = 1L;
    protected static final long SPECIFIED_FILL_RULE = 2L;
    protected static final long SPECIFIED_FILL_OPACITY = 4L;
    protected static final long SPECIFIED_STROKE = 8L;
    protected static final long SPECIFIED_STROKE_OPACITY = 16L;
    protected static final long SPECIFIED_STROKE_WIDTH = 32L;
    protected static final long SPECIFIED_STROKE_LINECAP = 64L;
    protected static final long SPECIFIED_STROKE_LINEJOIN = 128L;
    protected static final long SPECIFIED_STROKE_MITERLIMIT = 256L;
    protected static final long SPECIFIED_STROKE_DASHARRAY = 512L;
    protected static final long SPECIFIED_STROKE_DASHOFFSET = 1024L;
    protected static final long SPECIFIED_OPACITY = 2048L;
    protected static final long SPECIFIED_COLOR = 4096L;
    protected static final long SPECIFIED_FONT_FAMILY = 8192L;
    protected static final long SPECIFIED_FONT_SIZE = 16384L;
    protected static final long SPECIFIED_FONT_WEIGHT = 32768L;
    protected static final long SPECIFIED_FONT_STYLE = 65536L;
    protected static final long SPECIFIED_TEXT_DECORATION = 131072L;
    protected static final long SPECIFIED_TEXT_ANCHOR = 262144L;
    protected static final long SPECIFIED_OVERFLOW = 524288L;
    protected static final long SPECIFIED_CLIP = 1048576L;
    protected static final long SPECIFIED_MARKER_START = 2097152L;
    protected static final long SPECIFIED_MARKER_MID = 4194304L;
    protected static final long SPECIFIED_MARKER_END = 8388608L;
    protected static final long SPECIFIED_DISPLAY = 16777216L;
    protected static final long SPECIFIED_VISIBILITY = 33554432L;
    protected static final long SPECIFIED_STOP_COLOR = 67108864L;
    protected static final long SPECIFIED_STOP_OPACITY = 134217728L;
    protected static final long SPECIFIED_CLIP_PATH = 268435456L;
    protected static final long SPECIFIED_CLIP_RULE = 536870912L;
    protected static final long SPECIFIED_MASK = 1073741824L;
    protected static final long SPECIFIED_SOLID_COLOR = 2147483648L;
    protected static final long SPECIFIED_SOLID_OPACITY = 4294967296L;
    protected static final long SPECIFIED_VIEWPORT_FILL = 8589934592L;
    protected static final long SPECIFIED_VIEWPORT_FILL_OPACITY = 17179869184L;
    protected static final long SPECIFIED_VECTOR_EFFECT = 34359738368L;
    protected static final long SPECIFIED_DIRECTION = 68719476736L;
    protected static final long SPECIFIED_ALL = -1L;
    protected static final long SPECIFIED_NON_INHERITING = 68133849088L;

    protected SVG() {
    }

    public static SVG getFromInputStream(InputStream is) throws SVGParseException {
        SVGParser parser = new SVGParser();
        return parser.parse(is);
    }

    public static SVG getFromString(String svg) throws SVGParseException {
        SVGParser parser = new SVGParser();
        return parser.parse(new ByteArrayInputStream(svg.getBytes()));
    }

    public static SVG getFromResource(Context context, int resourceId) throws SVGParseException {
        return getFromResource(context.getResources(), resourceId);
    }

    public static SVG getFromResource(Resources resources, int resourceId) throws SVGParseException {
        SVGParser parser = new SVGParser();
        InputStream inputStream=resources.openRawResource(resourceId);
        return parser.parse(inputStream);
    }

    public static SVG getFromAsset(AssetManager assetManager, String filename) throws SVGParseException, IOException {
        SVGParser parser = new SVGParser();
        InputStream is = assetManager.open(filename);
        SVG svg = parser.parse(is);
        is.close();
        return svg;
    }

    public void registerExternalFileResolver(SVGExternalFileResolver fileResolver) {
        this.fileResolver = fileResolver;
    }

    public void setRenderDPI(float dpi) {
        this.renderDPI = dpi;
    }

    public float getRenderDPI() {
        return this.renderDPI;
    }

    public Picture renderToPicture() {
        SVG.Length width = this.rootElement.width;
        if (width != null) {
            float w = width.floatValue(this.renderDPI);
            SVG.Box rootViewBox = this.rootElement.viewBox;
            float h;
            if (rootViewBox != null) {
                h = w * rootViewBox.height / rootViewBox.width;
            } else {
                SVG.Length height = this.rootElement.height;
                if (height != null) {
                    h = height.floatValue(this.renderDPI);
                } else {
                    h = w;
                }
            }

            return this.renderToPicture((int)Math.ceil((double)w), (int)Math.ceil((double)h));
        } else {
            return this.renderToPicture(512, 512);
        }
    }

    public Picture renderToPicture(int widthInPixels, int heightInPixels) {
        Picture picture = new Picture();
        Canvas canvas = picture.beginRecording(widthInPixels, heightInPixels);
        SVG.Box viewPort = new SVG.Box(0.0F, 0.0F, (float)widthInPixels, (float)heightInPixels);
        SVGAndroidRenderer renderer = new SVGAndroidRenderer(canvas, viewPort, this.renderDPI);
        renderer.renderDocument(this, (Box)null, (PreserveAspectRatio)null, false);
        picture.endRecording();
        return picture;
    }

    public Picture renderViewToPicture(String viewId, int widthInPixels, int heightInPixels) {
        SVG.SvgObject obj = this.getElementById(viewId);
        if (obj == null) {
            return null;
        } else if (!(obj instanceof SVG.View)) {
            return null;
        } else {
            SVG.View view = (SVG.View)obj;
            if (view.viewBox == null) {
                Log.w("AndroidSVG", "View element is missing a viewBox attribute.");
                return null;
            } else {
                Picture picture = new Picture();
                Canvas canvas = picture.beginRecording(widthInPixels, heightInPixels);
                SVG.Box viewPort = new SVG.Box(0.0F, 0.0F, (float)widthInPixels, (float)heightInPixels);
                SVGAndroidRenderer renderer = new SVGAndroidRenderer(canvas, viewPort, this.renderDPI);
                renderer.renderDocument(this, view.viewBox, view.preserveAspectRatio, false);
                picture.endRecording();
                return picture;
            }
        }
    }

    public void renderToCanvas(Canvas canvas) {
        this.renderToCanvas(canvas, (RectF)null);
    }

    public void renderToCanvas(Canvas canvas, RectF viewPort) {
        SVG.Box svgViewPort;
        if (viewPort != null) {
            svgViewPort = SVG.Box.fromLimits(viewPort.left, viewPort.top, viewPort.right, viewPort.bottom);
        } else {
            svgViewPort = new SVG.Box(0.0F, 0.0F, (float)canvas.getWidth(), (float)canvas.getHeight());
        }

        SVGAndroidRenderer renderer = new SVGAndroidRenderer(canvas, svgViewPort, this.renderDPI);
        renderer.renderDocument(this, (SVG.Box)null, (PreserveAspectRatio)null, true);
    }

    public void renderViewToCanvas(String viewId, Canvas canvas) {
        this.renderViewToCanvas(viewId, canvas, (RectF)null);
    }

    public void renderViewToCanvas(String viewId, Canvas canvas, RectF viewPort) {
        SVG.SvgObject obj = this.getElementById(viewId);
        if (obj != null) {
            if (obj instanceof SVG.View) {
                SVG.View view = (SVG.View)obj;
                if (view.viewBox == null) {
                    Log.w("AndroidSVG", "View element is missing a viewBox attribute.");
                } else {
                    SVG.Box svgViewPort;
                    if (viewPort != null) {
                        svgViewPort = SVG.Box.fromLimits(viewPort.left, viewPort.top, viewPort.right, viewPort.bottom);
                    } else {
                        svgViewPort = new SVG.Box(0.0F, 0.0F, (float)canvas.getWidth(), (float)canvas.getHeight());
                    }

                    SVGAndroidRenderer renderer = new SVGAndroidRenderer(canvas, svgViewPort, this.renderDPI);
                    renderer.renderDocument(this, view.viewBox, view.preserveAspectRatio, true);
                }
            }
        }
    }

    public static String getVersion() {
        return "1.2.1";
    }

    public String getDocumentTitle() {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            return this.title;
        }
    }

    public String getDocumentDescription() {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            return this.desc;
        }
    }

    public String getDocumentSVGVersion() {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            return this.rootElement.version;
        }
    }

    public Set<String> getViewList() {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            List<SVG.SvgObject> viewElems = this.getElementsByTagName(SVG.View.class);
            Set<String> viewIds = new HashSet(viewElems.size());
            Iterator var4 = viewElems.iterator();

            while(var4.hasNext()) {
                SVG.SvgObject elem = (SVG.SvgObject)var4.next();
                SVG.View view = (SVG.View)elem;
                if (view.id != null) {
                    viewIds.add(view.id);
                } else {
                    Log.w("AndroidSVG", "getViewList(): found a <view> without an id attribute");
                }
            }

            return viewIds;
        }
    }

    public float getDocumentWidth() {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            return this.getDocumentDimensions(this.renderDPI).width;
        }
    }

    public void setDocumentWidth(float pixels) {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            this.rootElement.width = new SVG.Length(pixels);
        }
    }

    public void setDocumentWidth(String value) throws SVGParseException {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            try {
                this.rootElement.width = SVGParser.parseLength(value);
            } catch (SAXException var3) {
                throw new SVGParseException(var3.getMessage());
            }
        }
    }

    public float getDocumentHeight() {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            return this.getDocumentDimensions(this.renderDPI).height;
        }
    }

    public void setDocumentHeight(float pixels) {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            this.rootElement.height = new SVG.Length(pixels);
        }
    }

    public void setDocumentHeight(String value) throws SVGParseException {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            try {
                this.rootElement.height = SVGParser.parseLength(value);
            } catch (SAXException var3) {
                throw new SVGParseException(var3.getMessage());
            }
        }
    }

    public void setDocumentViewBox(float minX, float minY, float width, float height) {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            this.rootElement.viewBox = new SVG.Box(minX, minY, width, height);
        }
    }

    public RectF getDocumentViewBox() {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            return this.rootElement.viewBox == null ? null : this.rootElement.viewBox.toRectF();
        }
    }

    public void setDocumentPreserveAspectRatio(PreserveAspectRatio preserveAspectRatio) {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            this.rootElement.preserveAspectRatio = preserveAspectRatio;
        }
    }

    public PreserveAspectRatio getDocumentPreserveAspectRatio() {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            return this.rootElement.preserveAspectRatio == null ? null : this.rootElement.preserveAspectRatio;
        }
    }

    public float getDocumentAspectRatio() {
        if (this.rootElement == null) {
            throw new IllegalArgumentException("SVG document is empty");
        } else {
            SVG.Length w = this.rootElement.width;
            SVG.Length h = this.rootElement.height;
            if (w != null && h != null && w.unit != SVG.Unit.percent && h.unit != SVG.Unit.percent) {
                return !w.isZero() && !h.isZero() ? w.floatValue(this.renderDPI) / h.floatValue(this.renderDPI) : -1.0F;
            } else {
                return this.rootElement.viewBox != null && this.rootElement.viewBox.width != 0.0F && this.rootElement.viewBox.height != 0.0F ? this.rootElement.viewBox.width / this.rootElement.viewBox.height : -1.0F;
            }
        }
    }

    protected SVG.Svg getRootElement() {
        return this.rootElement;
    }

    protected void setRootElement(SVG.Svg rootElement) {
        this.rootElement = rootElement;
    }

    protected SVG.SvgObject resolveIRI(String iri) {
        if (iri == null) {
            return null;
        } else {
            return iri.length() > 1 && iri.startsWith("#") ? this.getElementById(iri.substring(1)) : null;
        }
    }

    private SVG.Box getDocumentDimensions(float dpi) {
        SVG.Length w = this.rootElement.width;
        SVG.Length h = this.rootElement.height;
        if (w != null && !w.isZero() && w.unit != SVG.Unit.percent && w.unit != SVG.Unit.em && w.unit != SVG.Unit.ex) {
            float wOut = w.floatValue(dpi);
            float hOut;
            if (h != null) {
                if (h.isZero() || h.unit == SVG.Unit.percent || h.unit == SVG.Unit.em || h.unit == SVG.Unit.ex) {
                    return new SVG.Box(-1.0F, -1.0F, -1.0F, -1.0F);
                }

                hOut = h.floatValue(dpi);
            } else if (this.rootElement.viewBox != null) {
                hOut = wOut * this.rootElement.viewBox.height / this.rootElement.viewBox.width;
            } else {
                hOut = wOut;
            }

            return new SVG.Box(0.0F, 0.0F, wOut, hOut);
        } else {
            return new SVG.Box(-1.0F, -1.0F, -1.0F, -1.0F);
        }
    }

    protected void addCSSRules(CSSParser.Ruleset ruleset) {
        this.cssRules.addAll(ruleset);
    }

    protected List<CSSParser.Rule> getCSSRules() {
        return this.cssRules.getRules();
    }

    protected boolean hasCSSRules() {
        return !this.cssRules.isEmpty();
    }

    protected void setTitle(String title) {
        this.title = title;
    }

    protected void setDesc(String desc) {
        this.desc = desc;
    }

    protected SVGExternalFileResolver getFileResolver() {
        return this.fileResolver;
    }

    protected SVG.SvgObject getElementById(String id) {
        return (SVG.SvgObject)(id.equals(this.rootElement.id) ? this.rootElement : this.getElementById(this.rootElement, id));
    }

    private SVG.SvgElementBase getElementById(SVG.SvgContainer obj, String id) {
        SVG.SvgElementBase elem = (SVG.SvgElementBase)obj;
        if (id.equals(elem.id)) {
            return elem;
        } else {
            Iterator var5 = obj.getChildren().iterator();

            while(var5.hasNext()) {
                SVG.SvgObject child = (SVG.SvgObject)var5.next();
                if (child instanceof SVG.SvgElementBase) {
                    SVG.SvgElementBase childElem = (SVG.SvgElementBase)child;
                    if (id.equals(childElem.id)) {
                        return childElem;
                    }

                    if (child instanceof SVG.SvgContainer) {
                        SVG.SvgElementBase found = this.getElementById((SVG.SvgContainer)child, id);
                        if (found != null) {
                            return found;
                        }
                    }
                }
            }

            return null;
        }
    }

    protected List<SVG.SvgObject> getElementsByTagName(Class clazz) {
        return this.getElementsByTagName(this.rootElement, clazz);
    }

    private List<SVG.SvgObject> getElementsByTagName(SVG.SvgContainer obj, Class clazz) {
        List<SVG.SvgObject> result = new ArrayList();
        if (obj.getClass() == clazz) {
            result.add((SVG.SvgObject)obj);
        }

        Iterator var5 = obj.getChildren().iterator();

        while(var5.hasNext()) {
            SVG.SvgObject child = (SVG.SvgObject)var5.next();
            if (child.getClass() == clazz) {
                result.add(child);
            }

            if (child instanceof SVG.SvgContainer) {
                this.getElementsByTagName((SVG.SvgContainer)child, clazz);
            }
        }

        return result;
    }

    /**
     * 相当于包含一个 x，y  width  height的rect
     */
    protected static class Box implements Cloneable {
        public float minX;
        public float minY;
        public float width;
        public float height;

        public Box(float minX, float minY, float width, float height) {
            this.minX = minX;
            this.minY = minY;
            this.width = width;
            this.height = height;
        }

        public static SVG.Box fromLimits(float minX, float minY, float maxX, float maxY) {
            return new SVG.Box(minX, minY, maxX - minX, maxY - minY);
        }

        public RectF toRectF() {
            return new RectF(this.minX, this.minY, this.maxX(), this.maxY());
        }

        public float maxX() {
            return this.minX + this.width;
        }

        public float maxY() {
            return this.minY + this.height;
        }

        public void union(SVG.Box other) {
            if (other.minX < this.minX) {
                this.minX = other.minX;
            }

            if (other.minY < this.minY) {
                this.minY = other.minY;
            }

            if (other.maxX() > this.maxX()) {
                this.width = other.maxX() - this.minX;
            }

            if (other.maxY() > this.maxY()) {
                this.height = other.maxY() - this.minY;
            }

        }

        public String toString() {
            return "[" + this.minX + " " + this.minY + " " + this.width + " " + this.height + "]";
        }
    }

    protected static class CSSClipRect {
        public SVG.Length top;
        public SVG.Length right;
        public SVG.Length bottom;
        public SVG.Length left;

        public CSSClipRect(SVG.Length top, SVG.Length right, SVG.Length bottom, SVG.Length left) {
            this.top = top;
            this.right = right;
            this.bottom = bottom;
            this.left = left;
        }
    }

    protected static class Circle extends SVG.GraphicsElement {
        public SVG.Length cx;
        public SVG.Length cy;
        public SVG.Length r;

        protected Circle() {
        }
    }

    protected static class ClipPath extends SVG.Group implements SVG.NotDirectlyRendered {
        public Boolean clipPathUnitsAreUser;

        protected ClipPath() {
        }
    }

    protected static class Colour extends SVG.SvgPaint {
        public int colour;
        public static final SVG.Colour BLACK = new SVG.Colour(0);

        public Colour(int val) {
            this.colour = val;
        }

        public String toString() {
            return String.format("#%06x", this.colour);
        }
    }

    protected static class CurrentColor extends SVG.SvgPaint {
        private static SVG.CurrentColor instance = new SVG.CurrentColor();

        private CurrentColor() {
        }

        public static SVG.CurrentColor getInstance() {
            return instance;
        }
    }

    protected static class Defs extends SVG.Group implements SVG.NotDirectlyRendered {
        protected Defs() {
        }
    }

    protected static class Ellipse extends SVG.GraphicsElement {
        public SVG.Length cx;
        public SVG.Length cy;
        public SVG.Length rx;
        public SVG.Length ry;

        protected Ellipse() {
        }
    }

    protected static class GradientElement extends SVG.SvgElementBase implements SVG.SvgContainer {
        public List<SVG.SvgObject> children = new ArrayList();
        public Boolean gradientUnitsAreUser;
        public Matrix gradientTransform;
        public SVG.GradientSpread spreadMethod;
        public String href;

        protected GradientElement() {
        }

        public List<SVG.SvgObject> getChildren() {
            return this.children;
        }

        public void addChild(SVG.SvgObject elem) throws SAXException {
            if (elem instanceof SVG.Stop) {
                this.children.add(elem);
            } else {
                throw new SAXException("Gradient elements cannot contain " + elem + " elements.");
            }
        }
    }

    protected static enum GradientSpread {
        pad,
        reflect,
        repeat;

        private GradientSpread() {
        }
    }

    protected abstract static class GraphicsElement extends SVG.SvgConditionalElement implements SVG.HasTransform {
        public Matrix transform;

        protected GraphicsElement() {
        }

        public void setTransform(Matrix transform) {
            this.transform = transform;
        }
    }

    protected static class Group extends SVG.SvgConditionalContainer implements SVG.HasTransform {
        public Matrix transform;

        protected Group() {
        }

        public void setTransform(Matrix transform) {
            this.transform = transform;
        }
    }

    protected interface HasTransform {
        void setTransform(Matrix var1);
    }

    protected static class Image extends SVG.SvgPreserveAspectRatioContainer implements SVG.HasTransform {
        public String href;
        public SVG.Length x;
        public SVG.Length y;
        public SVG.Length width;
        public SVG.Length height;
        public Matrix transform;

        protected Image() {
        }

        public void setTransform(Matrix transform) {
            this.transform = transform;
        }
    }

    protected static class Length implements Cloneable {
        float value = 0.0F;
        SVG.Unit unit;

        public Length(float value, SVG.Unit unit) {
            this.unit = SVG.Unit.px;
            this.value = value;
            this.unit = unit;
        }

        public Length(float value) {
            this.unit = SVG.Unit.px;
            this.value = value;
            this.unit = SVG.Unit.px;
        }

        public float floatValue() {
            return this.value;
        }

        public float floatValueX(SVGAndroidRenderer renderer) {
            //$SWITCH_TABLE$com$caverock$androidsvg$SVG$Unit()[this.unit.ordinal()]
            switch(this.unit.ordinal()) {
                case 1:
                    return this.value;
                case 2:
                    return this.value * renderer.getCurrentFontSize();
                case 3:
                    return this.value * renderer.getCurrentFontXHeight();
                case 4:
                    return this.value * renderer.getDPI();
                case 5:
                    return this.value * renderer.getDPI() / 2.54F;
                case 6:
                    return this.value * renderer.getDPI() / 25.4F;
                case 7:
                    return this.value * renderer.getDPI() / 72.0F;
                case 8:
                    return this.value * renderer.getDPI() / 6.0F;
                case 9:
                    SVG.Box viewPortUser = renderer.getCurrentViewPortInUserUnits();
                    if (viewPortUser == null) {
                        return this.value;
                    }

                    return this.value * viewPortUser.width / 100.0F;
                default:
                    return this.value;
            }
        }

        public float floatValueY(SVGAndroidRenderer renderer) {
            if (this.unit == SVG.Unit.percent) {
                SVG.Box viewPortUser = renderer.getCurrentViewPortInUserUnits();
                return viewPortUser == null ? this.value : this.value * viewPortUser.height / 100.0F;
            } else {
                return this.floatValueX(renderer);
            }
        }

        public float floatValue(SVGAndroidRenderer renderer) {
            if (this.unit == SVG.Unit.percent) {
                SVG.Box viewPortUser = renderer.getCurrentViewPortInUserUnits();
                if (viewPortUser == null) {
                    return this.value;
                } else {
                    float w = viewPortUser.width;
                    float h = viewPortUser.height;
                    if (w == h) {
                        return this.value * w / 100.0F;
                    } else {
                        float n = (float)(Math.sqrt((double)(w * w + h * h)) / 1.414213562373095D);
                        return this.value * n / 100.0F;
                    }
                }
            } else {
                return this.floatValueX(renderer);
            }
        }

        public float floatValue(SVGAndroidRenderer renderer, float max) {
            return this.unit == SVG.Unit.percent ? this.value * max / 100.0F : this.floatValueX(renderer);
        }

        public float floatValue(float dpi) {
            //$SWITCH_TABLE$com$caverock$androidsvg$SVG$Unit()[this.unit.ordinal()]
            switch(this.unit.ordinal()) {
                case 1:
                    return this.value;
                case 2:
                case 3:
                case 9:
                default:
                    return this.value;
                case 4:
                    return this.value * dpi;
                case 5:
                    return this.value * dpi / 2.54F;
                case 6:
                    return this.value * dpi / 25.4F;
                case 7:
                    return this.value * dpi / 72.0F;
                case 8:
                    return this.value * dpi / 6.0F;
            }
        }

        public boolean isZero() {
            return this.value == 0.0F;
        }

        public boolean isNegative() {
            return this.value < 0.0F;
        }

        public String toString() {
            return String.valueOf(this.value) + this.unit;
        }
    }

    protected static class Line extends SVG.GraphicsElement {
        public SVG.Length x1;
        public SVG.Length y1;
        public SVG.Length x2;
        public SVG.Length y2;

        protected Line() {
        }
    }

    protected static class Marker extends SVG.SvgViewBoxContainer implements SVG.NotDirectlyRendered {
        public boolean markerUnitsAreUser;
        public SVG.Length refX;
        public SVG.Length refY;
        public SVG.Length markerWidth;
        public SVG.Length markerHeight;
        public double orient;

        protected Marker() {
        }
    }

    protected static class Mask extends SVG.SvgConditionalContainer implements SVG.NotDirectlyRendered {
        public Boolean maskUnitsAreUser;
        public Boolean maskContentUnitsAreUser;
        public SVG.Length x;
        public SVG.Length y;
        public SVG.Length width;
        public SVG.Length height;

        protected Mask() {
        }
    }

    protected interface NotDirectlyRendered {
    }

    protected static class PaintReference extends SVG.SvgPaint {
        public String href;
        public SVG.SvgPaint fallback;

        public PaintReference(String href, SVG.SvgPaint fallback) {
            this.href = href;
            this.fallback = fallback;
        }

        public String toString() {
            return this.href + " " + this.fallback;
        }
    }

    protected static class Path extends SVG.GraphicsElement {
        public SVG.PathDefinition d;
        public Float pathLength;

        protected Path() {
        }
    }

    /**
     * 记录下命令和参数
     */
    protected static class PathDefinition implements SVG.PathInterface {
        private List<Byte> commands = null;
        private List<Float> coords = null;
        private static final byte MOVETO = 0;
        private static final byte LINETO = 1;
        private static final byte CUBICTO = 2;
        private static final byte QUADTO = 3;
        private static final byte ARCTO = 4;
        private static final byte CLOSE = 8;

        public PathDefinition() {
            this.commands = new ArrayList();
            this.coords = new ArrayList();
        }

        public boolean isEmpty() {
            return this.commands.isEmpty();
        }

        public void moveTo(float x, float y) {
            this.commands.add((byte)0);
            this.coords.add(x);
            this.coords.add(y);
        }

        public void lineTo(float x, float y) {
            this.commands.add((byte)1);
            this.coords.add(x);
            this.coords.add(y);
        }

        public void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) {
            this.commands.add((byte)2);
            this.coords.add(x1);
            this.coords.add(y1);
            this.coords.add(x2);
            this.coords.add(y2);
            this.coords.add(x3);
            this.coords.add(y3);
        }

        public void quadTo(float x1, float y1, float x2, float y2) {
            this.commands.add((byte)3);
            this.coords.add(x1);
            this.coords.add(y1);
            this.coords.add(x2);
            this.coords.add(y2);
        }

        public void arcTo(float rx, float ry, float xAxisRotation, boolean largeArcFlag, boolean sweepFlag, float x, float y) {
            int arc = 4 | (largeArcFlag ? 2 : 0) | (sweepFlag ? 1 : 0);
            this.commands.add((byte)arc);
            this.coords.add(rx);
            this.coords.add(ry);
            this.coords.add(xAxisRotation);
            this.coords.add(x);
            this.coords.add(y);
        }

        public void close() {
            this.commands.add((byte)8);
        }

        public void enumeratePath(SVG.PathInterface handler) {
            Iterator<Float> coordsIter = this.coords.iterator();
            Iterator var4 = this.commands.iterator();

            while(var4.hasNext()) {
                byte command = (Byte)var4.next();
                switch(command) {
                    case 0:
                        handler.moveTo((Float)coordsIter.next(), (Float)coordsIter.next());
                        break;
                    case 1:
                        handler.lineTo((Float)coordsIter.next(), (Float)coordsIter.next());
                        break;
                    case 2:
                        handler.cubicTo((Float)coordsIter.next(), (Float)coordsIter.next(), (Float)coordsIter.next(), (Float)coordsIter.next(), (Float)coordsIter.next(), (Float)coordsIter.next());
                        break;
                    case 3:
                        handler.quadTo((Float)coordsIter.next(), (Float)coordsIter.next(), (Float)coordsIter.next(), (Float)coordsIter.next());
                        break;
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    default:
                        boolean largeArcFlag = (command & 2) != 0;
                        boolean sweepFlag = (command & 1) != 0;
                        handler.arcTo((Float)coordsIter.next(), (Float)coordsIter.next(), (Float)coordsIter.next(), largeArcFlag, sweepFlag, (Float)coordsIter.next(), (Float)coordsIter.next());
                        break;
                    case 8:
                        handler.close();
                }
            }

        }
    }

    protected interface PathInterface {
        void moveTo(float var1, float var2);

        void lineTo(float var1, float var2);

        void cubicTo(float var1, float var2, float var3, float var4, float var5, float var6);

        void quadTo(float var1, float var2, float var3, float var4);

        void arcTo(float var1, float var2, float var3, boolean var4, boolean var5, float var6, float var7);

        void close();
    }

    protected static class Pattern extends SVG.SvgViewBoxContainer implements SVG.NotDirectlyRendered {
        public Boolean patternUnitsAreUser;
        public Boolean patternContentUnitsAreUser;
        public Matrix patternTransform;
        public SVG.Length x;
        public SVG.Length y;
        public SVG.Length width;
        public SVG.Length height;
        public String href;

        protected Pattern() {
        }
    }

    protected static class PolyLine extends SVG.GraphicsElement {
        public float[] points;

        protected PolyLine() {
        }
    }

    protected static class Polygon extends SVG.PolyLine {
        protected Polygon() {
        }
    }

    protected static class Rect extends SVG.GraphicsElement {
        public SVG.Length x;
        public SVG.Length y;
        public SVG.Length width;
        public SVG.Length height;
        public SVG.Length rx;
        public SVG.Length ry;

        protected Rect() {
        }
    }

    protected static class SolidColor extends SVG.SvgElementBase implements SVG.SvgContainer {
        public SVG.Length solidColor;
        public SVG.Length solidOpacity;

        protected SolidColor() {
        }

        public List<SVG.SvgObject> getChildren() {
            return SVG.EMPTY_CHILD_LIST;
        }

        public void addChild(SVG.SvgObject elem) throws SAXException {
        }
    }

    protected static class Stop extends SVG.SvgElementBase implements SVG.SvgContainer {
        public Float offset;

        protected Stop() {
        }

        public List<SVG.SvgObject> getChildren() {
            return SVG.EMPTY_CHILD_LIST;
        }

        public void addChild(SVG.SvgObject elem) throws SAXException {
        }
    }

    protected static class Style implements Cloneable {
        public long specifiedFlags = 0L;
        public SVG.SvgPaint fill;
        public SVG.Style.FillRule fillRule;
        public Float fillOpacity;
        public SVG.SvgPaint stroke;
        public Float strokeOpacity;
        public SVG.Length strokeWidth;
        public SVG.Style.LineCaps strokeLineCap;
        public SVG.Style.LineJoin strokeLineJoin;
        public Float strokeMiterLimit;
        public SVG.Length[] strokeDashArray;
        public SVG.Length strokeDashOffset;
        public Float opacity;
        public SVG.Colour color;
        public List<String> fontFamily;
        public SVG.Length fontSize;
        public Integer fontWeight;
        public SVG.Style.FontStyle fontStyle;
        public SVG.Style.TextDecoration textDecoration;
        public SVG.Style.TextDirection direction;
        public SVG.Style.TextAnchor textAnchor;
        public Boolean overflow;
        public SVG.CSSClipRect clip;
        public String markerStart;
        public String markerMid;
        public String markerEnd;
        public Boolean display;
        public Boolean visibility;
        public SVG.SvgPaint stopColor;
        public Float stopOpacity;
        public String clipPath;
        public SVG.Style.FillRule clipRule;
        public String mask;
        public SVG.SvgPaint solidColor;
        public Float solidOpacity;
        public SVG.SvgPaint viewportFill;
        public Float viewportFillOpacity;
        public SVG.Style.VectorEffect vectorEffect;
        public static final int FONT_WEIGHT_NORMAL = 400;
        public static final int FONT_WEIGHT_BOLD = 700;
        public static final int FONT_WEIGHT_LIGHTER = -1;
        public static final int FONT_WEIGHT_BOLDER = 1;

        protected Style() {
        }

        public static SVG.Style getDefaultStyle() {
            SVG.Style def = new SVG.Style();
            def.specifiedFlags = -1L;
            def.fill = SVG.Colour.BLACK;
            def.fillRule = SVG.Style.FillRule.NonZero;
            def.fillOpacity = 1.0F;
            def.stroke = null;
            def.strokeOpacity = 1.0F;
            def.strokeWidth = new SVG.Length(1.0F);
            def.strokeLineCap = SVG.Style.LineCaps.Butt;
            def.strokeLineJoin = SVG.Style.LineJoin.Miter;
            def.strokeMiterLimit = 4.0F;
            def.strokeDashArray = null;
            def.strokeDashOffset = new SVG.Length(0.0F);
            def.opacity = 1.0F;
            def.color = SVG.Colour.BLACK;
            def.fontFamily = null;
            def.fontSize = new SVG.Length(12.0F, SVG.Unit.pt);
            def.fontWeight = 400;
            def.fontStyle = SVG.Style.FontStyle.Normal;
            def.textDecoration = SVG.Style.TextDecoration.None;
            def.direction = SVG.Style.TextDirection.LTR;
            def.textAnchor = SVG.Style.TextAnchor.Start;
            def.overflow = true;
            def.clip = null;
            def.markerStart = null;
            def.markerMid = null;
            def.markerEnd = null;
            def.display = Boolean.TRUE;
            def.visibility = Boolean.TRUE;
            def.stopColor = SVG.Colour.BLACK;
            def.stopOpacity = 1.0F;
            def.clipPath = null;
            def.clipRule = SVG.Style.FillRule.NonZero;
            def.mask = null;
            def.solidColor = null;
            def.solidOpacity = 1.0F;
            def.viewportFill = null;
            def.viewportFillOpacity = 1.0F;
            def.vectorEffect = SVG.Style.VectorEffect.None;
            return def;
        }

        public void resetNonInheritingProperties() {
            this.resetNonInheritingProperties(false);
        }

        public void resetNonInheritingProperties(boolean isRootSVG) {
            this.display = Boolean.TRUE;
            this.overflow = isRootSVG ? Boolean.TRUE : Boolean.FALSE;
            this.clip = null;
            this.clipPath = null;
            this.opacity = 1.0F;
            this.stopColor = SVG.Colour.BLACK;
            this.stopOpacity = 1.0F;
            this.mask = null;
            this.solidColor = null;
            this.solidOpacity = 1.0F;
            this.viewportFill = null;
            this.viewportFillOpacity = 1.0F;
            this.vectorEffect = SVG.Style.VectorEffect.None;
        }

        protected Object clone() {
            try {
                SVG.Style obj = (SVG.Style)super.clone();
                if (this.strokeDashArray != null) {
                    obj.strokeDashArray = (SVG.Length[])this.strokeDashArray.clone();
                }

                return obj;
            } catch (CloneNotSupportedException var3) {
                throw new InternalError(var3.toString());
            }
        }

        public static enum FillRule {
            NonZero,
            EvenOdd;

            private FillRule() {
            }
        }

        public static enum FontStyle {
            Normal,
            Italic,
            Oblique;

            private FontStyle() {
            }
        }

        public static enum LineCaps {
            Butt,
            Round,
            Square;

            private LineCaps() {
            }
        }

        public static enum LineJoin {
            Miter,
            Round,
            Bevel;

            private LineJoin() {
            }
        }

        public static enum TextAnchor {
            Start,
            Middle,
            End;

            private TextAnchor() {
            }
        }

        public static enum TextDecoration {
            None,
            Underline,
            Overline,
            LineThrough,
            Blink;

            private TextDecoration() {
            }
        }

        public static enum TextDirection {
            LTR,
            RTL;

            private TextDirection() {
            }
        }

        public static enum VectorEffect {
            None,
            NonScalingStroke;

            private VectorEffect() {
            }
        }
    }

    protected static class Svg extends SVG.SvgViewBoxContainer {
        public SVG.Length x;
        public SVG.Length y;
        public SVG.Length width;
        public SVG.Length height;
        public String version;

        protected Svg() {
        }
    }

    protected interface SvgConditional {
        void setRequiredFeatures(Set<String> var1);

        Set<String> getRequiredFeatures();

        void setRequiredExtensions(String var1);

        String getRequiredExtensions();

        void setSystemLanguage(Set<String> var1);

        Set<String> getSystemLanguage();

        void setRequiredFormats(Set<String> var1);

        Set<String> getRequiredFormats();

        void setRequiredFonts(Set<String> var1);

        Set<String> getRequiredFonts();
    }

    /**
     * 拥有svg的的element ， container  conditional功能
     */
    protected static class SvgConditionalContainer extends SVG.SvgElement implements SVG.SvgContainer, SVG.SvgConditional {
        public List<SVG.SvgObject> children = new ArrayList();
        public Set<String> requiredFeatures = null;
        public String requiredExtensions = null;
        public Set<String> systemLanguage = null;
        public Set<String> requiredFormats = null;
        public Set<String> requiredFonts = null;

        protected SvgConditionalContainer() {
        }

        public List<SVG.SvgObject> getChildren() {
            return this.children;
        }

        public void addChild(SVG.SvgObject elem) throws SAXException {
            this.children.add(elem);
        }

        public void setRequiredFeatures(Set<String> features) {
            this.requiredFeatures = features;
        }

        public Set<String> getRequiredFeatures() {
            return this.requiredFeatures;
        }

        public void setRequiredExtensions(String extensions) {
            this.requiredExtensions = extensions;
        }

        public String getRequiredExtensions() {
            return this.requiredExtensions;
        }

        public void setSystemLanguage(Set<String> languages) {
            this.systemLanguage = languages;
        }

        public Set<String> getSystemLanguage() {
            return null;
        }

        public void setRequiredFormats(Set<String> mimeTypes) {
            this.requiredFormats = mimeTypes;
        }

        public Set<String> getRequiredFormats() {
            return this.requiredFormats;
        }

        public void setRequiredFonts(Set<String> fontNames) {
            this.requiredFonts = fontNames;
        }

        public Set<String> getRequiredFonts() {
            return this.requiredFonts;
        }
    }

    protected static class SvgConditionalElement extends SVG.SvgElement implements SVG.SvgConditional {
        public Set<String> requiredFeatures = null;
        public String requiredExtensions = null;
        public Set<String> systemLanguage = null;
        public Set<String> requiredFormats = null;
        public Set<String> requiredFonts = null;

        protected SvgConditionalElement() {
        }

        public void setRequiredFeatures(Set<String> features) {
            this.requiredFeatures = features;
        }

        public Set<String> getRequiredFeatures() {
            return this.requiredFeatures;
        }

        public void setRequiredExtensions(String extensions) {
            this.requiredExtensions = extensions;
        }

        public String getRequiredExtensions() {
            return this.requiredExtensions;
        }

        public void setSystemLanguage(Set<String> languages) {
            this.systemLanguage = languages;
        }

        public Set<String> getSystemLanguage() {
            return this.systemLanguage;
        }

        public void setRequiredFormats(Set<String> mimeTypes) {
            this.requiredFormats = mimeTypes;
        }

        public Set<String> getRequiredFormats() {
            return this.requiredFormats;
        }

        public void setRequiredFonts(Set<String> fontNames) {
            this.requiredFonts = fontNames;
        }

        public Set<String> getRequiredFonts() {
            return this.requiredFonts;
        }
    }

    protected interface SvgContainer {
        List<SVG.SvgObject> getChildren();

        void addChild(SVG.SvgObject var1) throws SAXException;
    }

    protected static class SvgElement extends SVG.SvgElementBase {
        public SVG.Box boundingBox = null;

        protected SvgElement() {
        }
    }

    protected static class SvgElementBase extends SVG.SvgObject {
        public String id = null;
        public Boolean spacePreserve = null;
        public SVG.Style baseStyle = null;
        public SVG.Style style = null;
        public List<String> classNames = null;

        protected SvgElementBase() {
        }
    }

    protected static class SvgLinearGradient extends SVG.GradientElement {
        public SVG.Length x1;
        public SVG.Length y1;
        public SVG.Length x2;
        public SVG.Length y2;

        protected SvgLinearGradient() {
        }
    }

    protected static class SvgObject {
        public SVG document;
        public SVG.SvgContainer parent;

        protected SvgObject() {
        }

        public String toString() {
            return this.getClass().getSimpleName();
        }
    }

    protected abstract static class SvgPaint implements Cloneable {
        protected SvgPaint() {
        }
    }

    protected static class SvgPreserveAspectRatioContainer extends SVG.SvgConditionalContainer {
        public PreserveAspectRatio preserveAspectRatio = null;

        protected SvgPreserveAspectRatioContainer() {
        }
    }

    protected static class SvgRadialGradient extends SVG.GradientElement {
        public SVG.Length cx;
        public SVG.Length cy;
        public SVG.Length r;
        public SVG.Length fx;
        public SVG.Length fy;

        protected SvgRadialGradient() {
        }
    }

    protected static class SvgViewBoxContainer extends SVG.SvgPreserveAspectRatioContainer {
        public SVG.Box viewBox;

        protected SvgViewBoxContainer() {
        }
    }

    protected static class Switch extends SVG.Group {
        protected Switch() {
        }
    }

    protected static class Symbol extends SVG.SvgViewBoxContainer implements SVG.NotDirectlyRendered {
        protected Symbol() {
        }
    }

    protected static class TRef extends SVG.TextContainer implements SVG.TextChild {
        public String href;
        private SVG.TextRoot textRoot;

        protected TRef() {
        }

        public void setTextRoot(SVG.TextRoot obj) {
            this.textRoot = obj;
        }

        public SVG.TextRoot getTextRoot() {
            return this.textRoot;
        }
    }

    protected static class TSpan extends SVG.TextPositionedContainer implements SVG.TextChild {
        private SVG.TextRoot textRoot;

        protected TSpan() {
        }

        public void setTextRoot(SVG.TextRoot obj) {
            this.textRoot = obj;
        }

        public SVG.TextRoot getTextRoot() {
            return this.textRoot;
        }
    }

    protected static class Text extends SVG.TextPositionedContainer implements SVG.TextRoot, SVG.HasTransform {
        public Matrix transform;

        protected Text() {
        }

        public void setTransform(Matrix transform) {
            this.transform = transform;
        }
    }

    protected interface TextChild {
        void setTextRoot(SVG.TextRoot var1);

        SVG.TextRoot getTextRoot();
    }

    protected static class TextContainer extends SVG.SvgConditionalContainer {
        protected TextContainer() {
        }

        public void addChild(SVG.SvgObject elem) throws SAXException {
            if (elem instanceof SVG.TextChild) {
                this.children.add(elem);
            } else {
                throw new SAXException("Text content elements cannot contain " + elem + " elements.");
            }
        }
    }

    protected static class TextPath extends SVG.TextContainer implements SVG.TextChild {
        public String href;
        public SVG.Length startOffset;
        private SVG.TextRoot textRoot;

        protected TextPath() {
        }

        public void setTextRoot(SVG.TextRoot obj) {
            this.textRoot = obj;
        }

        public SVG.TextRoot getTextRoot() {
            return this.textRoot;
        }
    }

    protected static class TextPositionedContainer extends SVG.TextContainer {
        public List<SVG.Length> x;
        public List<SVG.Length> y;
        public List<SVG.Length> dx;
        public List<SVG.Length> dy;

        protected TextPositionedContainer() {
        }
    }

    protected interface TextRoot {
    }

    protected static class TextSequence extends SVG.SvgObject implements SVG.TextChild {
        public String text;
        private SVG.TextRoot textRoot;

        public TextSequence(String text) {
            this.text = text;
        }

        public String toString() {
            return this.getClass().getSimpleName() + " '" + this.text + "'";
        }

        public void setTextRoot(SVG.TextRoot obj) {
            this.textRoot = obj;
        }

        public SVG.TextRoot getTextRoot() {
            return this.textRoot;
        }
    }

    protected static enum Unit {
        px,
        em,
        ex,
        in,
        cm,
        mm,
        pt,
        pc,
        percent;

        private Unit() {
        }
    }

    protected static class Use extends SVG.Group {
        public String href;
        public SVG.Length x;
        public SVG.Length y;
        public SVG.Length width;
        public SVG.Length height;

        protected Use() {
        }
    }

    protected static class View extends SVG.SvgViewBoxContainer implements SVG.NotDirectlyRendered {
        protected View() {
        }
    }
}
